﻿<?xml version="1.0" encoding="utf-8"?>
<!--
﻿// Copyright (c) 2010. Rusanu Consulting LLC  
// http://code.google.com/p/dbutilsqlcmd/
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// 
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
    <xsl:output method="text" indent="no" encoding="utf-8"/> 
    <xsl:template match="/">
#summary Some Summary
#labels Label1 Label2
#sidepar TableOfContents

<xsl:apply-templates select="/doc/assembly"/></xsl:template>

<xsl:template match="assembly">
=<xsl:value-of select="name"/>=
<xsl:apply-templates select="../members/member[starts-with(@name,'T:')]"/></xsl:template>
<xsl:template match="member[starts-with(@name,'T:')]" >
==<xsl:value-of select="substring-after(@name,'T:')"/>==
<xsl:apply-templates select="./summary"/>
  <xsl:variable name="type" select="substring(@name,3)"/>
  <xsl:call-template name="Members">
  <xsl:with-param name="api">Properties</xsl:with-param>
  <xsl:with-param name="type" select="$type"/>
    <xsl:with-param name="prefix">P:</xsl:with-param>
  <xsl:with-param name="members" select="../member[starts-with(@name, concat('P:', $type, '.'))]" />
</xsl:call-template>
<xsl:call-template name="Members">
  <xsl:with-param name="api">Methods</xsl:with-param>
  <xsl:with-param name="type" select="$type"/>
    <xsl:with-param name="prefix">M:</xsl:with-param>
  <xsl:with-param name="members" select="../member[starts-with(@name, concat('M:', $type, '.'))]" />
</xsl:call-template>
<xsl:call-template name="Members">
  <xsl:with-param name="api">Fields</xsl:with-param>
  <xsl:with-param name="type" select="$type"/>
     <xsl:with-param name="prefix">F:</xsl:with-param>
  <xsl:with-param name="members" select="../member[starts-with(@name, concat('F:', $type, '.'))]" />
</xsl:call-template>
</xsl:template>
<xsl:template name="Members">
  <xsl:param name="api"/>
  <xsl:param name="type"/>
  <xsl:param name="prefix"/>
  <xsl:param name="members"/>
<xsl:if test="count($members) > 0">
===<xsl:value-of select="$api"/>===
<xsl:value-of select="$type"/>
<xsl:for-each select="$members">
`<xsl:value-of select="substring-after(@name, concat($prefix, $type, '.'))"/>`
<xsl:apply-templates select="param"/>
<xsl:apply-templates select="summary"/>
</xsl:for-each>
</xsl:if>
</xsl:template>
<xsl:template match="summary">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="param">||`<xsl:value-of select="@name"/>`||<xsl:value-of select="text()"/><xsl:value-of select="'&#x0d;'"/></xsl:template>
</xsl:stylesheet>
